@import "@/styles/variables.module.less";

@field-box-width: 360px;
@widget-border-color: #3370ff;
@field-top-height: 48px;
@field-widget-min-height: 31.6px;

.form-make-box {
  display: flex;
  height: 100%;
  justify-content: space-between;
}

// 左侧属性栏
.form-fields-box {
  // position: absolute;
  // top: 0;
  // bottom: 0;
  // left: 0;
  // z-index: 1;
  width: @field-box-width;
  background-color: #fff;

  .fields-top {
    height: @field-top-height;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid #e8e8e8;
    font-size: 16px;
    color: #3370ff;
    font-weight: 400;
  }

  .fields-main {
    height: calc(100% - @field-top-height);
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px;

    .fields-box {
      + .fields-box {
        margin-top: 8px;
      }

      .title {
        margin-bottom: 8px;
        color: #1f2329;
      }

      .field-box-wrap {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
      }

      .field-box {
        margin-bottom: 16px;
        width: calc((100% - 16px) / 2);
        width: 148px;
        font-size: 14px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 4px 6px;
        border: 1px solid #e4e5e7;
        border-radius: 4px;
        cursor: grab;
        position: relative;
        color: #646a73;
        user-select: none;

        &:hover {
          border: 1px solid @widget-border-color;
          box-shadow: 0 4px 8px rgba(31, 35, 41, 0.03), 0 3px 6px -6px rgba(31, 35, 41, 0.05), 0 6px 18px 6px rgba(31, 35, 41, 0.03);
        }

        .field-icon {
          font-family: PingFang SC, Microsoft YaHei;
          font-size: 24px;
          color: #646a73;
        }
      }
    }
  }
}

// 中间组件栏
.form-layout-box {
  display: flex;
  align-items: center;

  .mobile-box {
    width: 400px;
    height: calc(100% - 30px);
    padding: 12px;
    // box-shadow: 2px 4px 12px 0 rgba(0, 0, 0, 0.16), inset 0 -1px 1px 0 #c9cbd5, inset -1px 0 4px 0 rgba(57, 63, 89, 0.09);
    border: 1px solid #eee;
    border-radius: 4px;
    background-color: #fff;
    border-radius: var(--border-radius-large);

    .mobile {
      border-radius: 4px;
      border: 1px solid rgba(0, 0, 0, 0.1);
      background-color: @MainContentBg;
      height: 100%;
      overflow: hidden;
      overflow-y: auto;
      position: relative;
      padding: 10px 0;

      .blank-tip {
        position: absolute;
        height: 110px;
        margin: 8px;
        width: calc(100% - 16px);
        color: #1f2329;
        border: 1px dashed #bbbfc4;
        border-radius: 4px;
        background: #fff;
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
  }

  .choosed-widgets-box {
    width: 100%;
    height: 100%;

    .ghost {
      border: 2px solid @widget-border-color;
      border-radius: 0;
      outline-width: 0;
      width: 100%;
      height: 3px;
      box-sizing: border-box;
      font-size: 0;
      content: "";
      overflow: hidden;
      padding: 0;
      margin: 10px 0;
    }

    .arco-form-item {
      margin-bottom: 0;
    }
  }
}

// 右侧属性设置栏
.form-setting-box {
  width: 360px;
  user-select: none;

  .select-options-box {
    width: 100%;

    .option-item {
      width: 100%;
      display: flex;
      align-items: center;
      margin-bottom: 8px;

      .option {
        flex: 1;
        margin-right: 10px;
      }

      .delete {
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 2px;
        &:hover {
          background-color: #f2f3f5;
        }
      }
    }
  }
}

// 中间组件栏的每个组件
.field-widget {
  width: 100%;
  background-color: #fff;
  border: 1px solid transparent;
  position: relative;
  user-select: none;
  margin-bottom: 10px;
  display: flex;
  align-items: center;

  &:hover {
    border-color: rgba(51, 112, 255, 0.5);
  }

  .widget-move {
    position: absolute;
    top: 0;
    left: 0;
    width: 15px;
    height: 15px;
    color: #fff;
    background-color: @widget-border-color;
    border-bottom-right-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
  }

  .widget-delete {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 15px;
    height: 15px;
    color: #fff;
    background-color: @widget-border-color;
    border-top-left-radius: 2px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    z-index: 2;
  }

  .form-item {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin: 10px;

    .form-item-name {
      width: 90px;
      line-height: 31.5px;
      text-align: right;
      font-weight: 400;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      padding-right: 8px;
    }

    .form-item-widget {
      flex: 1;
      margin-left: 10px;

      .arco-textarea-wrapper {
        display: block;
      }
    }
  }

  .form-tip {
    font-size: 14px;
    line-height: 22px;
    color: #646a73;
    padding: 3px 12px;
    word-break: break-word;
    background-color: rgba(31, 35, 41, 0.05);
    min-height: @field-widget-min-height;
  }

  .required {
    .form-item-name::after {
      content: "*";
      position: absolute;
      color: #f54a45;
      right: 0;
      top: 3px;
    }
  }

  .detail-required {
    .widget-detail-name::after {
      content: "*";
      position: absolute;
      top: 2px;
      color: #f54a45;
    }
  }
}

// 中间组件被选中
.field-widget-focus {
  border-color: @widget-border-color !important;

  .widget-delete {
    opacity: 1;
  }
}

// 明细组件
.form-item-widget-detail-box {
  width: 100%;
  position: relative;
  margin: 10px;

  .empty-detail {
    position: absolute;
    min-height: 32px;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: PingFang SC, Microsoft YaHei;
    font-size: 14px;
    line-height: 20px;
    color: #8f959e;
    text-align: center;
    background-color: #f8f9fa;
    border: 1px dashed #bbbfc4;
    border-radius: 4px;
  }

  .widget-detail-name {
    margin-bottom: 5px;
  }

  .widget-detail-box {
    min-height: 32px;
    background: #f5f6f7;
    border: 5px solid #f5f6f7;
  }

  .empty-box {
    border-width: 0;
    min-height: 40px;
    border-radius: 4px;

    &::after {
      content: "拖拽左侧控件至此处";
      position: absolute;
      top: 20px;
      left: 10px;
      right: 10px;
      bottom: 20px;
      display: flex;
      align-items: center;
      justify-content: center;
      font-family: PingFang SC, Microsoft YaHei;
      font-size: 14px;
      line-height: 20px;
      color: #8f959e;
      text-align: center;
      background-color: #f5f6f7;
      border-radius: 4px;
    }
  }

  .field-widget {
    margin-bottom: 0;

    + .field-widget {
      margin-top: 5px;
    }
  }
}
